package ai.people.netmon.telegram.support;

//import ai.people.core.security.support.RequestHolderUtil;
import ai.people.netmon.framework.domain.ucenter.request.LoginUser;
import org.springframework.core.MethodParameter;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

/**
 * 登录用户参数解析器
 *
 * @author yuanqinglong
 * @date 2022/2/14 17:45
 */
public class LoginUserArgumentResolver implements HandlerMethodArgumentResolver {

    StringRedisTemplate stringRedisTemplate;

    public LoginUserArgumentResolver(StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
    }

    @Override
    public boolean supportsParameter(MethodParameter parameter) {
        boolean assignable = parameter.getParameterType().isAssignableFrom(LoginUser.class);
        return assignable;
    }

    @Override
    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
        //return RequestHolderUtil.loginUser();
        return null;
    }
}
